﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Threading;
using System.Windows.Threading;
using System.Diagnostics;

namespace Bohdan.Arch.Messaging
{
    public abstract class GeneralDispatcherSubscriber : GeneralSingleThreadedSubscriber
    {
        protected Dispatcher _dispatcher;

        private void ProperProcessMessageImmediateCaller(object msg)
        {
            base.ProcessMessageImmediateCaller((GeneralMessage)msg);
        }

        protected override void ProcessMessageImmediateCaller(GeneralMessage msg)
        {
            _dispatcher.Invoke(new ParameterizedThreadStart(ProperProcessMessageImmediateCaller), msg);
        }

        public override ThreadPriority WorkerThreadPriority
        {
            get {
                return ThreadPriority.Normal;
            }
        }

        public GeneralDispatcherSubscriber(Dispatcher dispatcher)
        {
            this._dispatcher = dispatcher;
        }
    }
}
